package com.my.zidingyikongjian.view.one;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

/**
 * 项目名称：移动的线
 * 创建人：mwb
 * 创建时间：2018/6/28 11:03
 */

public class RemoveLine extends View {
    private float x1, y1, x2, y2;

    /**
     * @param context
     * @param x1
     * @param y1
     * @param x2
     * @param y2
     */
    public RemoveLine(Context context, float x1, float y1, float x2, float y2) {
        super(context);
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        Paint paint = new Paint();
        paint.setStrokeWidth(5);// 设置画笔宽度
        paint.setStyle(Paint.Style.FILL);// 画笔填充
        paint.setColor(Color.RED);

        // 先固定线条的长度
        canvas.drawRGB(255, 255, 255);
        canvas.drawLine(x1, y1, x2, y2, paint);
    }
}
